package Six;

import java.text.DecimalFormat;

public class Employee extends Person {
	private double salary;
	private Company company;
	public Employee(String name, int age, boolean gender, double salary, Company company){
		super(name,age,gender);
		this.salary=salary;
		this.company=company;
	}
	@Override
	public String toString() {
		return "Employee:"+super.toString()+"-"+this.company+"-"+this.salary;
	}
	
	public boolean equals(Object obj) {
		DecimalFormat df = new DecimalFormat("#.##");
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Employee other = (Employee) obj;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		if (df.format(salary)!=(df.format(other.salary)))
			return false;
		return true;
	}
	
}
